/**
 * Copyright (C) 2008 aileron.cc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cc.aileron.jww.admin.view.process;

import static cc.aileron.wsgi.navigation.WsgiNavigation.State.Continue;
import cc.aileron.jww.admin.model.logic.EditItemLogic;
import cc.aileron.jww.admin.model.logic.MenuItemLogic;
import cc.aileron.jww.admin.view.resources.PageResource;
import cc.aileron.wsgi.WsgiProcess;
import cc.aileron.wsgi.navigation.WsgiNavigation;

import com.google.inject.Inject;

/**
 * menu部分の実装
 * @author Aileron
 *
 */
public class MenuProcess implements WsgiProcess<PageResource>
{
    @Override
    public WsgiNavigation doProcess(final PageResource p) throws Exception
    {
        p.menu = menuItemLogic.getAll();
        if(p.selectItemId!=0)
        {
            p.edit = editItemLogic.get(p.selectItemId, 0);
        }
        return Continue.navigation();
    }
    
    @Inject
    public MenuProcess(
            final MenuItemLogic menuItemLogic,
            final EditItemLogic editItemLogic)
    {
        this.menuItemLogic = menuItemLogic;
        this.editItemLogic = editItemLogic;
    }
    
    /**
     * logic
     */
    private final EditItemLogic editItemLogic;
    
    /**
     * dao
     */
    private final MenuItemLogic menuItemLogic;
}
